<template>
  <div class="fastNavBox" :style="outModuleCss">
    <div :style="moduleBgCss" class="module-bg"></div>
    <div class="fastNav">
      <div class="navList">
        <template v-for="(item, index) in propsData.params.list">
          <template v-if="index == 0">
            <div
              :class="['navItem', 'choosed choosed1']"
              :key="index"
              v-if="propsData.params.choosedStyle.style == 1"
              :style="propsData.params.choosedStyle.css"
              @click.stop="chooseCurrent"
            >
              {{ item.text }}
              <div
                class="underLine"
                v-if="propsData.params.choosedStyle.style == 1"
                :style="{
                  backgroundColor: propsData.params.choosedStyle.lineColor,
                }"
              ></div>
            </div>
            <div
              :class="['navItem', 'choosed choosed2']"
              :key="index"
              :style="{
                ...propsData.params.choosedStyle.css,
                backgroundColor: propsData.params.choosedStyle.backgroundColor,
              }"
              v-else
              @click.stop="chooseCurrent"
            >
              {{ item.text }}
            </div>
          </template>
          <div
            class="navItem"
            :key="index"
            v-else
            :style="propsData.params.css"
          >
            {{ item.text }}
          </div>
        </template>
      </div>
      <div class="allNav">
        <span
          class="iconfont icon-weibiaoti-17"
          :style="{
            color: propsData.params.css.color,
          }"
          v-if="!showAll"
          @click.stop="showAll = !showAll"
        ></span>
        <span
          class="iconfont icon-weibiaoti-16"
          v-else
          @click.stop="showAll = !showAll"
          :style="{
            color: propsData.params.css.color,
          }"
        ></span>
      </div>
    </div>
  </div>
</template>

<script>
import { mixinsModuleCss } from "@/components/DiyNew/diy/mixins/index.js";

export default {
  name: "fastNav",
  props: {
    propsData: {
      type: Object,
      default: {},
    },
  },
  mixins: [mixinsModuleCss],
  data() {
    return {
      showAll: false,
      choosedCurrent: false,
    };
  },
  mounted() {
    console.log(this.propsData, "fastNav");
  },
  watch: {},
  computed: {},
  methods: {
    // 选择当前状态
    chooseCurrent() {
      this.choosedCurrent = true;
      this.$emit("chooseMoudle", this.propsData.params.choosedStyle);
    },
  },
};
</script>

<style lang="scss" scoped>
.fastNavBox {
  width: 100%;
}
.fastNav {
  width: 100%;
  // height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  .navList {
    flex: auto;
    width: 0;
    overflow-x: auto;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    padding: 5px 0;
    .navItem {
      position: relative;
      margin-right: 20px;
    }
    .choosed:hover::before {
      cursor: pointer;
      content: "\e657";
      font-family: "iconfont";
      position: absolute;
      right: 0;
      top: 0;
      width: 20px;
      height: 20px;
      background-color: #1890fc;
      border-radius: 0 0 0 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      color: #fff;
    }
    .choosed:hover::after {
      cursor: pointer;
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      border: 1px solid #1890fc;
    }
    .underLine {
      position: absolute;
      width: 100%;
      height: 3px;
      background-color: #fff;
      bottom: -3px;
      left: 0;
      z-index: 100;
    }
    .choosed2 {
      padding: 0 10px;
      border-radius: 99px;
      background-color: pink;
    }
    .current {
      cursor: pointer;
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      z-index: 100;
    }
    .choosedTab {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      border: 1px solid #1890fc;
    }
  }
  .navList::-webkit-scrollbar {
    display: none;
  }
  .allNav {
    width: 25px;
    min-width: 25px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    .iconfont {
      font-size: 12px;
    }
  }
}
.module-bg {
  width: 100%;
  height: 100%;
  z-index: -1;
  position: absolute;
  left: 0;
  top: 0;
}
</style>
